//by k1 2020.6.19

if (isNil "Move_out_Dead") then {
	Move_out_Dead = {
		params ["_u", "_v"];
		if (!alive _v) exitWith {};
		_t = time + 1;
		waitUntil {_u in _v || {time >_t}};
		if !(_u in _v) exitWith {};
		_u setPosASL getPosASL _u;
		_t = time + 1;
		waitUntil {!(_u in _v) || {time >_t}};
	};
	MoveOut_Dead_main = {
		_v = _this;
		_grp = createGroup [civilian, true];
		_u = _grp createUnit ["C_man_1", [0,0,0], [], 0, "FORM"];
		_u allowDamage false;
		_u hideObjectGlobal true;
		{
			_x params ["_d", "_role", "_CargoIndex", "_turretPath"];
			if (!alive _d) then {
				switch true do {
					case (_role == "driver"): {_u moveInDriver _v};
					case (_role == "commander"): {_u moveInCommander _v};
					case (_role == "Turret" || {_role == "gunner"}): {_u moveInTurret [_v, _turretPath]};
					case (_role == "cargo"): {_u moveInCargo [_v, _CargoIndex]};
				};
				[_u, _v] call Move_out_Dead;
			};
		} forEach fullCrew _v;
		deleteVehicle _u;
	};
	"MoveOut_Dead_v" addPublicVariableEventHandler {(_this select 1) spawn MoveOut_Dead_main};
};



